package com.gimi.test_jpa.com.gimi.controller.customer;

import com.gimi.test_jpa.com.gimi.dto.customer.CustomerContactInfoDto;
import com.gimi.test_jpa.com.gimi.service.customer.CustomerContactInfoService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

@Api(description = "客户联系信息控制层")
@RequestMapping("api/info")
@RestController
public class CustomerContactInfoController {
    @Autowired
    private CustomerContactInfoService contactInfoService;

    @ApiOperation("创建修改客户联系信息")
    @PostMapping("/createAndUpdateCusInfo")
    public Boolean createAndUpdate(@RequestBody CustomerContactInfoDto contactInfoDto){
        if (contactInfoDto.getCusContactId()==null){
            throw new RuntimeException("主键参数为空");
        }
        return contactInfoService.createAndUpdate(contactInfoDto);
    }

    @ApiOperation("根据电话号码查询实体")
    @PostMapping("/findbyCusPhone")
    public List<CustomerContactInfoDto> findbyCusPhone(String cusPhone ,String cusEmail){
        return contactInfoService.findbyCusPhone(cusPhone,cusEmail);
    }
}
